{template $cfg['floder'].'/header'}
<script src="{MODULE_URL}template/resources/js/swiper.min.js"></script>
<script src="{MODULE_URL}template/resources/js/dragscroll.js"></script>
<link href="{MODULE_URL}template/resources/js/swiper.min.css" rel="stylesheet">
<style>
html,body{height:100%; overflow:hidden;}
body{ padding:10px 15px}
.mainbody{margin-top:68px; position:relative}
.page_left{float:left;width:310px;max-width:310px;}
a:link,a:visited,a:hover,a:active{ text-decoration:none;}
.page_right{float:right;}
.left_top{ background:#FFF; position:relative; padding:10px 5px;display:-webkit-box;display:box; margin-bottom:5px}
.left_top span:first-child{ display:block;-webkit-box-flex:1;box-flex:1;max-width:38px;width:38px;text-align:center;line-height:30px;color:#999;font-size:20px}
.left_top span:last-child{display:block;text-align:right; line-height:30px;color:#999;font-size:20px;}
.left_top span:nth-child(2){display:block;-webkit-box-flex:11;box-flex:11;}
.left_top input{ border:none; background:none; margin:0;padding:0; font-size:14px; height:30px;}
.left_menu{ background:#FFF;}
.menu_bar{ padding:10px; border-bottom:1px #DDD solid;line-height:30px;}
.temp_1{display:-webkit-box;display:box;}
.temp_1 .til{-webkit-box-flex:6;box-flex:6;}
.temp_1 .num{-webkit-box-flex:4;box-flex:4;max-width:90px;width:90px;text-align:center}
.temp_1 .price{-webkit-box-flex:2;box-flex:2; text-align:right;max-width:80px;width:80px;}
.temp_1 span{ color:#F66; font-weight:bold;}
.menu_bar b{color:#F66; font-weight:normal}
#Txt_search{ width:100%;}
.listmenu{ overflow:hidden; border-bottom:1px solid #DDD;}
.listmenu li{ padding:10px;border-bottom:1px solid #DDD; cursor:pointer;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center; height:40px;}
.listmenu li .til{ width:120px;}
.listmenu li .numinput{max-width:90px;width:90px;text-align:center;vertical-align:middle}
.listmenu li .priceinput{text-align:right;max-width:80px;width:80px;color:#FF5722;vertical-align:middle}
.listmenu li .txt_num{ display:inline-block; width:30px;}
.listmenu li .btnmenu{ color:#999}
.listmenu li .btnmenu:active{ color:#F66}
.listmenu li .priceinput s{ display:block; text-align:right; color:#666; font-size:60%;}
.listmenu li.isselect{background:#EEE;}
.listmenu li.isselect .btnmenu{color:#FF5722}

.left_menu_btngroup{border-bottom:1px #DDD solid;border-top:1px #DDD solid;line-height:24px;}
.left_menu_btngroup a{ display:block; text-align:center; line-height:40px;}
.left_menu_btngroup a:hover{color:#fff; background:#F66}
.left_menu_btngroup a.isselect{color:#fff; background:#F66}
.left_menu_btngroup1{line-height:24px;}
.left_menu_btngroup1 ul{ padding:10px 0;}
.left_menu_btngroup1 ul li{ padding:0 10px; font-size:18px;}
.menubtnpay{line-height:46px; height:46px;display:-webkit-box;display:box;}
.menubtnpay .btnprint{-webkit-box-flex:6;box-flex:6;text-align:center; color:#FFF;border-right:1px solid #EEE;}
.menubtnpay .btnpay{-webkit-box-flex:6;box-flex:6;text-align:center;color:#FFF}
.menubtnpay button{ background:#F66;color:#FFF;font-size:16px; border:none; display:block; width:100%;}
.menubtnpay button i{ font-size:24px;}

.page_middle{float:left;width:90px; margin:0 24px}
.page_middle li{ margin:0 0 5px 0; cursor:pointer; text-align:center; padding:15px 0; background:#FFF; font-size:16px;}
.page_middle li.info{ background:#886dd3; color:#FFF;}
.page_middle li.success{ background:#90b82d; color:#FFF;}

.right_topbar{height:50px;line-height:50px;overflow:hidden;position:relative;padding:0 50px;}
.right_topbar_btnleft{position:absolute;left:0;top:0;width:50px;text-align:center;background:#90b82d; z-index:1;color:#FFF;cursor:pointer}
.right_topbar_btnright{position:absolute;right:0;top:0;width:50px;text-align:center;background:#90b82d;z-index:1;color:#FFF;cursor:pointer}

.right_topmenu{margin:0;padding:0;height:50px;width:100%;}
.right_topmenu .swiper-slide{display:-webkit-box;display:-webkit-flex;display:flex;}
.right_topmenu .swiper-slide a{display:block; background:#FFF; text-align:center; height:50px; line-height:50px; margin-right:10px; width:100%}
.right_topmenu .isselect a{background:#F66; color:#FFF;}

.right_goodslist{overflow:hidden; margin-top:10px;}
.right_goodslist .swiper-container{width:100%;height:300px;padding:0;margin:0}
.right_goodslist .swiper-slide {display:-webkit-box;display:-webkit-flex;display:flex;}
ul.goodlist{ width:100%; height:100%;}
ul.goodlist li{width:32.5%; max-width:170px;display:inline-block; margin:0 0 10px 0; text-align:left;}
ul.goodlist li a{display:block;margin-right:10px; background:#FFF; position:relative;}
ul.goodlist li a .img{display:block;height: 100px;overflow: hidden;}
ul.goodlist li a .info{ padding:5px;}
ul.goodlist li a .info h3{ font-size:14px; margin:0; padding:0; text-align:left; line-height:24px; margin-bottom:5px}
ul.goodlist li a .info p{ margin-bottom:5px}
ul.goodlist li a:active{ background:#F66; color:#FFF}
.pt_menuitem a{display:block; text-align:center;border-bottom:2px solid #FFF;line-height:38px; width:100%}
.pt_menubar .isselect a{border-bottom:2px solid #F60;}
.pt_status{ padding:20px 0;}

.cirle{display:inline-block; width:14px; height:14px; border-radius:100%; background:#CCC;}
.cirle_red{background:#F66;}
.cirle_success{background:#91ba30;}
.page_table_list{ clear:both; padding:0 50px}
.page_table_list .swiper-container{width:100%;padding:0;margin:0}
.page_table_list .swiper-slide{display:-webkit-box;display:-webkit-flex;display:flex;}
.page_table_list ul{ width:100%;  height:100%}
.page_table_list li{height:150px; min-width:110px; max-width:150px;margin:0 0 10px 0; width:20%; display:inline-block }
.page_table_list li a{display:block;height:150px;margin-right:5px;border:1px solid #CCC;padding:5px;}
.page_table_list li a h2{ margin:15px 0; padding:10px; text-align:center; font-size:20px; line-height:20px;}
.page_table_list li a .pt_label span{ display:inline-block; padding:2px 3px; border-radius:4px; color:#FFF; background:#F66; font-size:60%}
.pt_tablelist .status_0 a{ background:#FFF;}
.pt_tablelist .status_1 a{ background:#8fb82c;color:#FFF}
.pt_tablelist .status_2 a{ background:#ff6666;color:#FFF}
.page_table_list li.isselect a{background:#EEE;color:#000}
#txt_tablename{ color:#F00; font-size:16px;}

.extension span{ display:inline-block; padding:2px; font-size:60%; border-radius:4px; background:#F66;color:#FFF;}
.extension .ispack{ background:#F66;}
.extension .ispay{ background:#90b82d;}
.taste{font-size:60%;}
.label{font-size:80%;}
.label-red{ background:#F66; color:#FFF;}

::-webkit-scrollbar  {width:6px;height: 16px;background-color:#F5F5F5;  }  
::-webkit-scrollbar-track  {-webkit-box-shadow:inset 0 0 6px rgba(0,0,0,0.3);border-radius:10px;background-color:#F5F5F5;}  
::-webkit-scrollbar-thumb  {border-radius:10px;-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);background-color: #555;}  
</style>
<section class="mainbody">
  <aside class="page_left">
    <form class="layui-form" id="form_search" onsubmit="return searchgoods();return false;" action="">
    <div class="left_top">
      <span onclick="fun_showinput()"><i class="fa fa-font"></i></span>
      <span><input type="text" name="Txt_search" id="Txt_search" placeholder="条码/助词码（大写）/价格（0~10000)"/></span>
      <span class="btnremove" onclick="$('#Txt_search').val('');$('#Txt_search').focus();"><i class="fa fa-remove-sign"></i></span>
    </div>
    <input type="submit" lay-submit="" id="btnsearch" lay-filter="btnsearch" style="display:none;"/>
    </form>
    
    <form class="layui-form" id="form_menu" action="">
    <input type="hidden" name="orderid" id="orderid" />
    <div class="left_menu">
    	<div class="menu_bar" onclick="$('.listmenu li').removeClass('isselect');">
        	<div class="row">
            	<div class="col-md-5">单号：<span id="txt_tablename"></span></div>
            </div>
            <div class="temp_1">
            	<div class="til">品名 <span></span></div>
                <div class="num">数量 <span></span></div>
                <div class="price">金额</div>
            </div>
        </div>
        <div class="pl_menubox swiper-container">
          <ul class="swiper-wrapper listmenu">
           
          </ul>
        </div>
        <div class="left_menu_btngroup lm_btngroup">
        	<div class="row">
            	<div class="col-md-6 text-center"><a href="javascript:" onclick="fun_munebtn_clear()">清空</a></div>
                <div class="col-md-6 text-center"><a href="javascript:fun_selectholdorder()" id="btn_getback">取单</a><a href="javascript:" id="btn_submitorder" onclick="fun_munebtn_submitorder(1)" style="display:none">挂单</a></div>
            </div>
        </div>
        <div class="left_menu_btngroup1">
        	<input type="hidden" id="menu_memberid"/>
            <input type="hidden" id="menu_discount" value="100"/>
        	<ul>
            	<li><span class="pull-right"><span class="layui-badge layui-bg-orange">余额</span>￥<b id="menu_membercash">0.00</b></span> <b>会员</b> <Span id="menu_membercardno"></Span></li>
                <li><span class="pull-right">￥<b id="menu_order">0.00</b></span> <b>合计</b></li>
                <li><span class="pull-right">￥<b id="menu_couponfee">0.00</b></span> <b>优惠</b></li>
                <li><span class="pull-right" style="color:#F60">￥<b id="menu_total">0.00</b></span> <b>应付</b></li>
            </ul>
        </div>
        <div class="menubtnpay">
        	<div class="btnprint">
            	<button type="button" onclick="fun_selectmember()">选择会员</button>
            </div>
            <div class="btnpay"><button type="button" lay-submit="" id="btnpay" lay-filter="btnpay">收款</button></div>
        </div>
    </div>
    </form>
  </aside>
  <aside class="page_middle">
    <ul>
        <li class="success" onclick="fun_newOrder(0)">开单</li>
        <li onclick="funSys_keyboard()">快录</li>
        <li onclick="funmenu_number(0)">口味</li>
        <li onclick="funmenu_number(1)">数量</li>
        <li onclick="funmenu_number(5)">打包</li>
        {if $user["permission"]>2}
        <li onclick="funmenu_number(2)">折扣</li>
        <li onclick="funmenu_number(3)">改价</li>
        {/if}
        <li onclick="funmenu_number(4)">删除</li>
        <li onclick="funExtend_charge()">充值</li>
        <li onclick="funExtend_member()">会员</li>
        <li onclick="funExtend_history()">交易</li>
        <li onclick="funExtend_gift()">兑换</li>
        {php $btnlist=json_decode($shop['btnlist'],true)}
        {if count($btnlist)}
        {loop $btnlist $index $row}
        <li onclick="funExtend_btn(this)" url="{$row}">{$index}</li>
        {/loop}
        {/if}
    </ul>
  </aside>
  <aside class="page_right">
    <div class="right_topbar">
      <div class="right_topbar_btnleft"><i class="fa fa-menu-left"></i></div>
      <div class="right_topmenu swiper-container">
        <div class="swiper-wrapper">
          {if $isfungood}
          <div class="swiper-slide" gcid="-1"><a href="javascript:" onclick="fun_selectgoodpcate(-1)">活动商品</a></div>{/if}
          {if $isNoPcate}<div class="swiper-slide" gcid="0"><a href="javascript:" onclick="fun_selectgoodpcate(0)">未分类</a></div>{/if}
          {loop $goodpcatelist $row}
          <div class="swiper-slide" gcid="{$row['id']}"><a href="javascript:" onclick="fun_selectgoodpcate({$row['id']})">{$row['title']}</a></div>
          {/loop}
        </div>
      </div>
      <div class="right_topbar_btnright"><i class="fa fa-menu-right"></i></div>
    </div>
    <div class="right_goodslist">
    	<div class="swiper-container">
            <div class="swiper-wrapper">
                
            </div>
        </div>
    </div>
  </aside>
</section>

<style>
.modal_counter{background:#EEE;padding:15px;}
.modal_counter .modal_body{ padding:0; overflow:hidden}
.modal_counter .modal_body a{ display:block; line-height:55px;box-shadow:0 0 4px #CCC; border-radius:4px; background:#FFF;font-size:25px; text-align:center;}
.bl{ display:inline-block; width:190px}
.bl li{ display:inline-block;width:55px;margin-right:5px;margin-bottom:8px}
.br{ float:right}
.br li{ width:80px;}
.modal_btn_big{height:110px; width:110px; text-align:center; border:1px solid #CCC; border-radius:4px; margin:5px;font-size:24px; background:#FFF}
.modal_btn_big:active,.modal_btn_big:hover{ background:#F66; color:#FFF; }
.modal_tastebox{ text-align:center; padding:10px;}
.modal_tastebox span{ border:1px solid #CCC; display:inline-block; padding:5px; min-width:60px; margin:5px; text-align:center; border-radius:4px; cursor:pointer}
.modal_tastebox span.isselect{ border-color:#90b82d; background:#90b82d; color:#FFF;}
.modal_customgoodbox{ text-align:center; padding:10px;}
.modal_customgoodbox span{ border:1px solid #CCC; display:inline-block; padding:5px; min-width:60px; margin:5px; text-align:center; border-radius:4px; cursor:pointer}
.modal_customgoodbox span.isselect{ border-color:#90b82d; background:#90b82d; color:#FFF;}
</style>
<div class="modal_counter" style="display:none;">
	<div class="moad_inputbox">
    	<input type="text" readonly id="moadConterInput" maxlength="10" />
        <span onclick="$('#moadConterInput').val('')"><i class="fa fa-remove-sign"></i></span>
    </div>
    <div class="modal_body">
    	<div class="bl">
        	<ul>
            	<li><a href="javascript:" onclick="Counter(7,'#moadConterInput')">7</a></li>
                <li><a href="javascript:" onclick="Counter(8,'#moadConterInput')">8</a></li>
                <li><a href="javascript:" onclick="Counter(9,'#moadConterInput')">9</a></li>
                <li><a href="javascript:" onclick="Counter(4,'#moadConterInput')">4</a></li>
                <li><a href="javascript:" onclick="Counter(5,'#moadConterInput')">5</a></li>
                <li><a href="javascript:" onclick="Counter(6,'#moadConterInput')">6</a></li>
                <li><a href="javascript:" onclick="Counter(1,'#moadConterInput')">1</a></li>
                <li><a href="javascript:" onclick="Counter(2,'#moadConterInput')">2</a></li>
                <li><a href="javascript:" onclick="Counter(3,'#moadConterInput')">3</a></li>
                <li style="width:120px"><a href="javascript:" onclick="Counter(0,'#moadConterInput')">0</a></li>
                <li id="modal_doc"><a href="javascript:" onclick="Counter('.','#moadConterInput')">.</a></li>
            </ul>
        </div>
        <div class="br">
        <li style="margin-bottom:8px"><a href="javascript:" id="modal_cantrl"  style=" background:#50a4ec;font-size:20px;color:#FFF">取消</a></li>
        <li><a href="javascript:" id="modal_sure"  style=" background:#1bb987;font-size:24px;color:#FFF; height:180px; padding-top:40px">确<br/>定</a></li>
        </div>
    </div>
</div>

<div class="modal_customgood" style="display:none;">
	<div class="modal_customgoodbox">
    	<span taste="无码商品">无码商品</span>
    	{php $tasteAry=explode('|',$shop['customgood']);}
        {loop $tasteAry $row}
        <span taste="{$row}">{$row}</span>
        {/loop}
    </div>
</div>


<style>
.modal_selectorder {padding:15px 0;}
.modal_selectorderbox{ padding:10px; background:#FFF;}
.modal_selectorderbox ul{ height:400px; overflow:hidden;border:1px solid #CCC;}
.modal_selectorderbox ul li{ padding:10px; border-bottom:1px solid #CCC; cursor:pointer;}
.modal_selectorderbox ul li.isselect{ background:#e3eff5}

</style>
<div class="modal_selectorder" style="display:none;">
    <div class="modal_selectorderbox">
        <div class="pull-left" style="width:260px;margin-right:10px;">
        	<ul class="dragscroll modal_selectorderlist">
            	
            </ul>
        </div>
        <div class="pull-right" style="width:470px;">
        	<ul class="dragscroll">
            	<table class="layui-table" lay-even lay-skin="nob" style="margin:0">
                	<thead>
                      <tr>
                        <th>条码</th>
                        <th>名称</th>
                        <th>数量</th>
                        <th>金额</th>
                      </tr> 
                    </thead>
                    <tbody class="modal_selectorderlist2">
                      
                    </tbody>
                </table>
            </ul>
        </div>
        
    </div>
    <div class="text-right" style="padding:10px 20px; clear:both">
    	<button type="button" class="layui-btn layui-btn-small layui-btn-normal modal_selectorderbtn1 " style="width:90px">取回 </button>
        <button type="button" class="layui-btn layui-btn-small layui-btn-danger modal_selectorderbtn2 " style="width:90px"> 删除 </button>
        <button type="button" class="layui-btn layui-btn-small layui-btn-primary modal_selectorderbtn3 " style="width:90px"> 关闭</button>
    </div>
</div>
<style>
.modal_memberselect{padding:20px;}
.modal_memberselectmemberinfo{ border:1px solid #CCC; border-radius:4px; padding:4px 0}
.modal_memberselectmemberinfo .jrow{ border-bottom:1px solid #CCC;display:-webkit-box;display:box; padding:0 10px;}
.modal_memberselectmemberinfo .jrow:last-child{ border-bottom:none;}
.modal_memberselectmemberinfo .jrow div{ line-height:30px; padding:5px 0;}
.modal_memberselectmemberinfo .jrow .flex1{-webkit-box-flex:1;box-flex:1;}
.modal_memberselectmemberinfo .jrow .flex2{-webkit-box-flex:2;box-flex:2;}
.modal_memberselectmemberinfo .jrow .flex6{-webkit-box-flex:6;box-flex:6;}
.modal_memberselectmemberinfo .jrow .flex8{-webkit-box-flex:8;box-flex:8;}
.modal_memberselectmemberinfo .jrow .flex10{-webkit-box-flex:10;box-flex:10;}
.modal_memberselectmemberinfo .jrow label{ display:inline-block; margin-right:10px;}
.modal_memberselectpaytype{ padding:15px 0; }
.modal_memberselectpaytype .layui-form-radio{ padding-right:0}
.modal_memberselectfeebox input{ border:1px solid #CCC; background:#FFF; width:100%; font-size:16px; height:40px; border-radius:4px; padding:5px 10px; display:block; margin:0 0 10px 0}
.modal_memberselectfun span{display:inline-block;width:24.5%;margin:0 0 10px 0; text-align:center;}
.modal_memberselectfun span a{ display:block; text-align:center; padding:5px 0; border-radius:4px; border:1px solid #CCC; margin:0 3px; background:#FFF; color:#000; font-size:80%;}
.modal_memberselectfun span.isselect a{ border-color:#90b82d; background:#90b82d; color:#FFF;}
.modal_memberselectbtn{background:#DDD;-webkit-display:flex;display:flex;flex-direction:row;flex-wrap:wrap; padding:5px; position:relative}
.modal_memberselectbtn .btn0{width:70px; height:50px; border:1px solid #CCC; margin:5px; background:#FFF; font-size:26px; text-align:center; vertical-align:middle; border-radius:4px; line-height:50px;}
.modal_memberselectbtn .btn1{background:#50a4ec; color:#FFF;}
.modal_memberselectfoot{ padding:20px; text-align:right;}
.modal_memberselectfoot .layui-form-switch{ margin-top:0; font-size:16px;}
</style>
<div class="modal_memberselect" style="display:none">
  <div>
      <div class="pull-left" style="width:330px; margin-right:10px">
      	  <form class="layui-form" onsubmit="return modal_memberselectsearch();return false;" action="">
          <div class="modal_memberselectmemberinfo">
              <div class="jrow">
                  <div class="flex2"><span><i class="fa fa-barcode"></i></span></div>
                  <div class="flex8"><input type="text" id="modal_memberselectsearchtxt" style="background:none;border:none; width:100%; height:30px; font-size:16px; color:#999" maxlength="20" placeholder="刷卡或者输入卡号"/></div>
                  <div class="flex2" onclick="modal_memberselectsearch();"><span><i class="fa fa-search"></i></span></div>
              </div>
              <div class="jrow">
                  <div class="flex6" style="max-width:154px; min-width:154px;"><label>姓名</label><span id="mms_realname"></span></div>
                  <div class="flex6" style="max-width:154px;min-width:154px;"><label>电话</label><span id="mms_mobile"></span></div>
              </div>
              <div class="jrow">
                  <div class="flex6" style="max-width:154px;min-width:154px;"><label>等级</label><span id="mms_level">0</span></div>
                  <div class="flex6" style="max-width:154px;min-width:154px;"></div>
              </div>
              <div class="jrow">
                  <div class="flex6" style="max-width:154px;min-width:154px;"><label>余额</label><span id="mms_cash">0</span></div>
                  <div class="flex6" style="max-width:154px;min-width:154px;"><label>积分</label><span id="mms_credit">0</span></div>
              </div>
          </div>
          <input type="hidden" id="mms_memberid"/>
          <input type="submit" style="display:none;" onclick="modal_memberselectsearch();" />
          </form>
      </div>
      <div class="pull-left" style="width:250px">
        <div class="modal_memberselectbtn">
        	<a href="#" class="btn0">7</a>
            <a href="#" class="btn0">8</a>
            <a href="#" class="btn0">9</a>
            <a href="#" class="btn0">4</a>
            <a href="#" class="btn0">5</a>
            <a href="#" class="btn0">6</a>
            <a href="#" class="btn0">1</a>
            <a href="#" class="btn0">2</a>
            <a href="#" class="btn0">3</a>
            <a href="#" class="btn0">0</a>
            <a href="#" class="btn0">.</a>
            <a href="#" class="btn0 btn1"><i class="fa fa-remove-sign"></i></a>
        </div>
      </div>
      <div style="clear:both; padding:10px 0; text-align:right;">
      	<button type="button" class="layui-btn layui-btn-normal mms_btnok">选择该会员</button> 
        <button type="button" class="layui-btn mms_btnclose">关闭</button> 
        
      </div>
  </div>
</div>

<div class="modal_taste" style="display:none;">
    <div class="modal_tastebox">

    </div>
</div>
{template $cfg['floder'].'/tpl_paybox'}
{template $cfg['floder'].'/tpl_charge'}
{template $cfg['floder'].'/tpl_member'}
{template $cfg['floder'].'/tpl_history'}
{template $cfg['floder'].'/tpl_sys'}
{template $cfg['floder'].'/tpl_gift'}
{template $cfg['floder'].'/tpl_handover'}
{template $cfg['floder'].'/tpl_keyboard'}

<iframe src="" id="print_iframe" name="print_iframe" style="width:1px; height:1px;"></iframe>
<script language="javascript">
var tablePcateswiper=null;
var goodsListSwiper=null;
var menuListSwiper=null;
var memuListSwiperSize=0;
$(document).ready(function(e) {
    if($(window).width()>=1660){
        location.href="{php echo $this->createMobileUrl('index')}";
    }
	$(document).bind("keyup",function(event){
		if(event.keyCode == 8){
			  return false;
		}
	});
	$("#print_iframe").attr("src","jetsumprint://order?event=open&shopid={php echo $shopid}&userid={php echo $userid}&weid={$_W['uniacid']}");
    var height=$(window).height()-88;
	var menuheight=height-350;
	$(".pl_menubox").height(menuheight);
	$(".page_right").width($(window).width()-$(".page_left").width()-$(".page_middle").width()-48-30);
	$(".right_goodslist .swiper-container").height(height-65);
	goodsListSwiper = new Swiper('.right_goodslist .swiper-container');
	
	memuListSwiperSize=parseInt(menuheight/60);
	var swiper_goodpcate = new Swiper('.right_topmenu', {
		nextButton: '.right_topbar_btnleft',
		prevButton: '.right_topbar_btnright',
		slidesPerView: 6,
	});
	menuListSwiper = new Swiper('.pl_menubox',{direction:'vertical',slidesPerView:memuListSwiperSize,mousewheelControl:true,});
});
layui.use(['layer', 'laypage', 'element','form'], function(){
	var layer = layui.layer
	,laypage = layui.laypage
	,element = layui.element
	,form = layui.form;
	$(".right_topmenu a").eq(0).click();

	form.on('submit(btnpay)', function(data){
		var orderid=$("#orderid").val();
		if(!orderid){
			layer.msg("请选择订单",{icon:2,time:2000});
			return false;
		}
        if(!$(".listmenu li").size()){
            layer.msg("请先选择商品",{icon:2,time:2000});
            return false;
        }
		fun_munebtn_submitorder(0);
		return false;
	});
	
	//--------测试用

});
function searchgoods(){
	if(!$("#orderid").val()){
		layer.msg("请先开单",{icon:2,time:1000});
		return false;
	}
	var keyword=$("#Txt_search").val();
	if(!keyword){
		layer.msg("请输入内容",{icon:2,time:1000});
		return false;
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'searchgood'))}",{keyword:keyword},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		$("#Txt_search").val('').focus();
		var result=eval("("+returnstr+")");
		if(result.success){
			var goods=result.goods;
			if(!goods){
				layer.msg("无此商品",{icon:2,time:1000});
				return false;
			}
			if(parseInt(goods.id)==0){
				fun_insertCustomGood(goods);
				return;
			}
			if($(".listmenu li[gid='"+gid+"']").size()){
				var tt=$(".listmenu li[gid='"+gid+"']");
				var price=parseFloat(tt.attr("price"));
				var num=parseInt(tt.find(".txt_num").text())+1;
				var total=((str2num(price)*num)*0.01).toFixed(2);
				tt.find(".txt_num").text(num);
				$(".listmenu li[gid='"+gid+"'] .priceinput span").text("￥"+total);
			}else{
				var index=$(".listmenu li").size()+1;
				var price=goods.marketprice;
				var mprice=goods.memberprice;
				var title=goods.title;
				var goodsn=goods.goodsn;
				var gid=goods.id;
				var fprice=price;
				if(parseInt($("#menu_memberid").val()) && str2num(mprice)>0)fprice=mprice;
				menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="'+gid+'" goodsn="'+goodsn+'" title="'+title+'" price="'+fprice+'" mprice="'+mprice+'" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste"></div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+fprice+'</span> <s>'+(fprice!=price ? price : '')+'</s></div></li>');
				$(".listmenu").css("overflow","visible");
				menuListSwiper.updateSlidesSize();
				menuListSwiper.slideTo(0);
			}
			fun_sumTotal();
		}else{
			layer.msg(result.msg,{icon:2,time:1000});
			return false;
		}
		
	});
	return false;
}
function fun_insertCustomGood(goods){
	layer.open({
		type: 1,
		title:"自定义商品",
		area:'440px',
		skin: 'layui-layer-rim',
		content:$(".modal_customgood").show(),
		btn:['确认','取消'],
		btn1:function(indexs,layero){
			var index=$(".listmenu li").size()+1;
			var price=goods.marketprice;
			var title=$(".modal_customgoodbox .isselect").text();
			menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="0" goodsn="" title="'+title+'" price="'+price+'" mprice="0" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste"></div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+price+'</span> <s></s></div></li>');
			$(".listmenu").css("overflow","visible");
			menuListSwiper.updateSlidesSize();
			menuListSwiper.slideTo(0);
			fun_sumTotal();
			layer.close(indexs);
		},
		success: function(layero, index){
			$(".modal_customgoodbox span").bind("click",function(){
				$(this).addClass("isselect").siblings().removeClass("isselect");
			});
			$(".modal_customgoodbox span:eq(0)").click();
		},
		end:function(){
			$(".modal_customgood").hide();
			$(".modal_customgoodbox span").unbind("click");
			$(".modal_customgoodbox span").removeClass("isselect");
		}
	});
}
function fun_showinput(){
	if(!$("#orderid").val()){
		layer.msg("请先开单",{icon:2,time:1000});
		return;
	}
	fun_modal({
		"title":"价格（0~10000)",
		"type":true,
		"success":function(inputval,index){
			layer.close(index);
			$("#Txt_search").val(inputval);
			$("#btnsearch").click();
		}
	});
}
function fun_selectmenu(obj){
	var Index=$(obj).index();
	$(obj).addClass("isselect").siblings().removeClass("isselect");
}
function fun_selectmember(){
	if(!$("#orderid").val()){
		layer.msg("请先开单",{icon:2,time:1000});
		return;
	}
	layer.open({
		type: 1,
		title:0,
		area:"650px",
		skin: 'layui-layer-rim',
		content:$(".modal_memberselect").show(),
		success: function(layero, index){
			$("#modal_memberselectsearchtxt").val('');
			$("#mms_memberid").val('');
			$("#mms_realname").text('');
			$("#mms_mobile").text('');
			$("#mms_level").text('');
			$("#mms_discount").text('100%');
			$("#mms_credit").text('');
			$("#mms_cash").text('');
			$(".modal_memberselectbtn .btn0").bind("click",function(){
				if($(this).hasClass("btn1")){
					$("#modal_memberselectsearchtxt").val("");
				}else{
					var txt=$("#modal_memberselectsearchtxt").val();
					$("#modal_memberselectsearchtxt").val(txt+$(this).text());
				}
			});
			$(".mms_btnclose").bind("click",function(){
				layer.close(index);
			});
			$(".mms_btnok").bind("click",function(){
				if(!$("#mms_memberid").val()){
					layer.msg("请先搜索会员",{icon:2,time:1000});
					return false;
				}
				layer.close(index);
				$("#menu_memberid").val($("#mms_memberid").val());
				var cardname=$("#mms_realname").text();
				if($("#mms_realname").text().length==0)cardname=$("#mms_realname").attr("cardno");
				$("#menu_membercardno").text(cardname);
				$("#menu_membercash").text($("#mms_cash").text());
				fun_sumTotal();
			});
            $('#modal_memberselectsearchtxt').focus();
            $(document).unbind('keydown').bind('keydown',function(event){
                var keycode=parseInt(event.keyCode);
                if((keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
                    if($('#modal_memberselectsearchtxt').is(":focus"))return;
                    var temp=keycode<=57 ? 48 : 96;
                    Counter(keycode-temp,'#modal_memberselectsearchtxt');
                }else if(keycode==13 || keycode==110){
                    $("#modal_sure").click();
                }else if(keycode==46){
                    if($('#modal_memberselectsearchtxt').is(":focus"))return;
                    Counter(".",'#modal_memberselectsearchtxt');
                }else if(keycode==27){
                    if($('#modal_memberselectsearchtxt').val()!="0"){
                        $('#modal_memberselectsearchtxt').val("0");
                    }else{
                        layer.close(index);
                    }
                    return false;
                }else if(keycode==8 || keycode==116){
                    return false;
                }
            });
		},
		end:function(){
			$(".modal_memberselect").hide();
			$(".modal_memberselectfun span").unbind("click");
			$(".modal_memberselectbtn .btn0").unbind("click");
			$(".mms_btnclose").unbind("click");
			$(".mms_btnok").unbind("click");
            $(document).unbind("keydown");
		}
	});
}
function modal_memberselectsearch(){
	if(!$("#modal_memberselectsearchtxt").val())return false;;
	var keyword=$("#modal_memberselectsearchtxt").val();
	if(!keyword){
		layer.msg("请输入卡号或者电话号码",{icon:2,time:2000},function(){$("#modal_memberselectsearchtxt").focus()});
		return false;
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getmember'))}",{keyword:keyword},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(!result.success){
			layer.msg(result.msg,{icon:2,time:1000});
			return false;
		}
		var member=result.member;
		var cost=result.cost;
		$("#mms_memberid").val(member.id);
		$("#mms_realname").attr("cardno",member.cardno);
		$("#mms_realname").text(member.realname);
		$("#mms_mobile").text(member.mobile);
		$("#mms_credit").text(member.credit2);
		$("#mms_cash").text(member.cash2);
		$("#mms_level").text(member.level);
		return false;
	});
	return false;
}
function funmenu_number(type){
	if(!$(".listmenu .isselect").size()){
		layer.msg("请先选择要修改的内容",{icon:2,time:1000});
		return;
	}
	switch(type){
        case 0://口味
            layer.open({
                type: 1,
                title:"选择属性",
                area:'440px',
                skin: 'layui-layer-rim',
                content:$(".modal_taste").show(),
                btn:['确认','取消'],
                btn1:function(index,layero){
                    var temp=[];
                    $(".modal_tastebox .isselect").each(function(index, element) {
                        temp.push($(this).text());
                    });
                    $(".listmenu .isselect").find(".taste").text(temp.join(','));
                    layer.close(index);
                },
                success: function(layero, index){
                    var gid = $(".listmenu .isselect").attr("gid");
                    var index2=layer.load(1, {shade: [0.1,'#fff']});
                    $.post("{php echo $this->createMobileUrl('index',array('op'=>'getgood'))}",{id:gid},function(returnstr) {
                        layer.close(index2);
                        console.log(returnstr);
                        var result = eval("(" + returnstr + ")");
                        if (result.success) {
                            var goods=result.goods;
                            if(goods.taste.length<1){
                                layer.msg("该商品无属性选择",{icon:2,time:1500});
                                layer.close(index);
                            }
                            var oldtaste = $(".listmenu .isselect").find(".taste").text().split(",");
                            var goodstaste=goods["taste"].split("|");
                            $(".modal_tastebox").empty();
                            for(var i in goodstaste){
                                if($.inArray(goodstaste[i], oldtaste)>-1){
                                    $(".modal_tastebox").append("<span class='isselect'>"+goodstaste[i]+"</span>");
                                }else{
                                    $(".modal_tastebox").append("<span>"+goodstaste[i]+"</span>");
                                }
                            }
                            $(".modal_tastebox span").bind("click",function(){
                                if($(this).hasClass("isselect")){
                                    $(this).removeClass("isselect");
                                }else{
                                    $(this).addClass("isselect");
                                }
                            });
                        }else{
                            layer.msg(result.msg,{icon:2,time:1500});
                            layer.close(index);
                            return;
                        }
                    });
                },
                end:function(){
                    $(".modal_taste").hide();
                    $(".modal_tastebox span").unbind("click");
                }
            });
            break;
		case 1://数量
			fun_modal({
				"title":"修改数量",
				"type":false,
				"success":function(inputval,index){
					layer.close(index);
					$(".listmenu .isselect .txt_num").text(inputval);
					var num=parseInt(inputval);
					var gid=parseInt($(".listmenu .isselect").attr("gid"));
					var mid=parseInt($(".listmenu .isselect").attr("mid"));
					if(!gid){
						var price=parseFloat($(".listmenu .isselect").attr("price"));
						var total=(num*price).toFixed(2);
						$(".listmenu .isselect .priceinput span").text("￥"+total);
						fun_sumTotal();
						return;
					}
					var index2=layer.load(1, {shade: [0.1,'#fff']});
					$.post("{php echo $this->createMobileUrl('index',array('op'=>'selectgood'))}",{id:gid,num:num,mid:mid},function(returnstr){
						layer.close(index2);
						console.log(returnstr);
						var result=eval("("+returnstr+")");
						if(result.success){
							var price=parseFloat($(".listmenu .isselect").attr("price"));
							var total=(num*price).toFixed(2);
							$(".listmenu .isselect .priceinput span").text("￥"+total);
							fun_sumTotal();
						}else{
							layer.msg(result.msg,{icon:2,time:1500});
							return;
						}
					});
				}
			});
		break;
		case 2://折扣
			var price=parseFloat($(".listmenu .isselect").attr("price"));
			var oprice=parseFloat($(".listmenu .isselect").attr("oprice"));
			var discount=parseInt(price/oprice*100);
			fun_modal({
				"title":"修改折扣",
				"type":false,
				"tips":"当前折扣"+discount,
				"success":function(inputval,index){
					layer.close(index);
					var num=parseInt($(".listmenu .isselect .txt_num").text());
					var newpirce=(parseInt(inputval)*0.01*oprice);
					var total=(num*newpirce).toFixed(2);
					$(".listmenu .isselect .priceinput span").text("￥"+total);
					$(".listmenu .isselect").attr("price",newpirce.toFixed(2));
					var total2=(num*oprice).toFixed(2);
					$(".listmenu .isselect .priceinput s").text("￥"+total2);
					fun_sumTotal();
				}
			});
		break;
		case 3://改价
			var price=parseFloat($(".listmenu .isselect").attr("price"));
			var oprice=parseFloat($(".listmenu .isselect").attr("oprice"));
			fun_modal({
				"title":"修改单价",
				"type":true,
				"tips":"当前单价￥"+price,
				"success":function(inputval,index){
					layer.close(index);
					var num=parseInt($(".listmenu .isselect .txt_num").text());
					var newpirce=parseFloat(inputval);
					var total=(num*newpirce).toFixed(2);
					$(".listmenu .isselect").attr("price",newpirce.toFixed(2));
					var total2=(num*oprice).toFixed(2);
					$(".listmenu .isselect .priceinput span").text("￥"+total);
					$(".listmenu .isselect .priceinput s").text("￥"+total2);
					fun_sumTotal();
				}
			});
		break;
		case 4://删除
			var index=$(".listmenu .isselect").index();
			menuListSwiper.removeSlide(index);
			menuListSwiper.update();
            $(".right_topmenu a").eq(0).click();
			fun_sumTotal();
		break;
        case 5://打包
            var target=$(".listmenu .isselect .taste").text();
            if(target.indexOf("打包")>-1){
                var temp=target.replace("打包","");
                $(".listmenu .isselect .taste").text(temp);
            }else{
                var temp=target+" 打包";
                $(".listmenu .isselect .taste").text(temp);
            }
            break;
	}
}
function fun_sumTotal(){
	/*当有会员时*/
	var order=0;
	var total=0;
	var num1=0
	if(parseInt($("#menu_memberid").val())){
		$(".listmenu li").each(function(index, element) {
			var num=parseInt($(this).find(".txt_num").text());
			num1+=num;
			var mprice=str2num(($(this).attr('mprice')));
			var price=str2num(($(this).attr('price')));
			var oprice=str2num(($(this).attr('oprice')));
			if(mprice && price>mprice){
				price=mprice;
				$(this).attr('price',$(this).attr('mprice'));
				var fee=price*num;
                $(this).find(".priceinput").find("span").text("￥"+fee2num(fee));
				total+=fee;
			}else{
				total+=str2num(($(this).find(".priceinput").text().replace("￥","")));
			}
			order+=num*oprice;
		});
	}else{
		/*当无会员时*/
		$(".listmenu li").each(function(index, element) {
			total+=str2num(($(this).find(".priceinput").text().replace("￥","")));
			var num=parseInt($(this).find(".txt_num").text());
			num1+=num;
			var price=str2num(($(this).attr('oprice')));
			order+=num*price;
		});
	}
	$("#menu_order").text((order*0.01).toFixed(2));
	$("#menu_total").text((total*0.01).toFixed(2));
	$("#menu_couponfee").text(((order-total)*0.01).toFixed(2));
	$(".temp_1 .til span").text($(".listmenu .priceinput").size());
	$(".temp_1 .num span").text(num1);
}

function fun_selectgood(gid){
	if(!$("#orderid").val()){
		layer.msg("请先开单",{icon:2,time:1000});
		return;
	}
	if($(".goodlist li[gid='"+gid+"'] .mstore").size()){
		var remain=parseInt($(".goodlist li[gid='"+gid+"'] .mstore").text().replace("剩：",""));
		if(remain==0){
			layer.msg("库存不足",{icon:2,time:1000});
			return;
		}
	}
    var taste=arguments.length>1 ? arguments[1] : "";
    if($(".goodlist li[gid='"+gid+"']").attr("taste") && arguments.length==1){
        fun_selectTaste(gid);
        return;
    }
    var oTarget=$(".goodlist li[gid='"+gid+"']");
    var index=$(".listmenu li").size()+1;
    var price=oTarget.attr("price");
    var mprice=oTarget.attr("mprice");
    var title=oTarget.attr("title");
    var goodsn=oTarget.attr("goodsn");
    var fprice = price;
    if(parseInt($("#menu_memberid").val())){
        if(str2num(mprice)>0)fprice=mprice;
    }
    menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="'+gid+'" goodsn="'+goodsn+'" title="'+title+'" price="'+fprice+'" mprice="'+mprice+'" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste">'+taste+'</div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+fprice+'</span> <s>'+(fprice!=price ? price : '')+'</s></div></li>');
    $(".listmenu").css("overflow","visible");
    menuListSwiper.updateSlidesSize();
    menuListSwiper.slideTo(0);
	//---修改显示库存---//
	if($(".goodlist li[gid='"+gid+"'] .mstore").size()){
		var remain=parseInt($(".goodlist li[gid='"+gid+"'] .mstore").text().replace("剩：",""));
        $(".goodlist li[gid='"+gid+"'] .mstore").text("剩："+(remain-1));
	}
	fun_sumTotal();
	
}
function fun_selectTaste(gid){
    layer.open({
        type: 1,
        title:"选择口味",
        area:'440px',
        skin: 'layui-layer-rim',
        content:$(".modal_taste").show(),
        btn:['确认','取消'],
        btn1:function(index,layero){
            var temp=[];
            $(".modal_taste .isselect").each(function(index, element) {
                temp.push($(this).text());
            });
            fun_selectgood(gid,temp.join(','));
            layer.close(index);
        },
        success: function(layero, index){
            var tastestr=$(".goodlist li[gid='"+gid+"']").attr("taste");
            var tasteary=tastestr.split("|");
            $(".modal_tastebox").empty();
            for(var i in tasteary){
                $(".modal_tastebox").append("<span>"+tasteary[i]+"</span>");
            }
            $(".modal_tastebox span").bind("click",function(){
                if($(this).hasClass("isselect")){
                    $(this).removeClass("isselect");
                }else{
                    $(this).addClass("isselect");
                }
            });
        },
        end:function(){
            $(".modal_taste").hide();
            $(".modal_tastebox span").unbind("click");
        }
    });
}
function fun_selectholdorder(){
	layer.open({
		type: 1,
		title:"取回订单",
		area:'780px',
		skin: 'layui-layer-rim',
		content:$(".modal_selectorder").show(),
		success: function(layero, index){
			var index2=layer.load(1, {shade: [0.1,'#fff']});
			$.post("{php echo $this->createMobileUrl('index',array('op'=>'getholdorderlist'))}",{},function(returnstr){
				layer.close(index2);
				console.log(returnstr);
				var result=eval("("+returnstr+")");
				if(result.success){
					var list=result.list;
					$(".modal_selectorderlist").empty();
					for(var i in list){
						var temp='<li oid="'+list[i].id+'" onclick="mda_selectOrder('+list[i].id+')"><span class="pull-right">'+fromatTime(list[i].createtime)+'</span> <span class="layui-badge-dot layui-bg-green"></span> 单号：'+list[i].serialnum+' </li>';
						$(".modal_selectorderlist").append(temp);
					}
				}else{
					layer.msg(result.msg,{icon:2,time:1000});
					return false;
				}
				
			});
			$(".modal_selectorderbtn1").bind("click",function(){
				if(!$(".modal_selectorderlist .isselect").size()){
					layer.msg("请选择订单",{icon:2,time:1000});
					return ;
				}
				if($("#orderid").val()){
					layer.confirm('已有订单在处理，是否挂单？', {}, function(indexd){
						layer.close(indexd);
						fun_munebtn_submitorder(1);
					});
					return;
				}
				var orderid=$(".modal_selectorderlist .isselect").attr("oid");
				fun_newOrder(orderid);
				layer.closeAll();
			});
			$(".modal_selectorderbtn2").bind("click",function(){
				if(!$(".modal_selectorderlist .isselect").size()){
					layer.msg("请选择订单",{icon:2,time:1000});
					return ;
				}
				var orderid=$(".modal_selectorderlist .isselect").attr("oid");
				layer.confirm('确认删除此订单？', {}, function(indexd){
					layer.close(indexd);
					var index2=layer.load(1, {shade: [0.1,'#fff']});
					$.post("{php echo $this->createMobileUrl('index',array('op'=>'clearorder'))}",{orderid:orderid},function(returnstr){
						layer.close(index2);
						var result=eval("("+returnstr+")");
						if(result.success){
							$(".modal_selectorderlist .isselect").remove();
							$(".modal_selectorderlist2").empty();
						}
					});
					
				});
			});
			$(".modal_selectorderbtn3").bind("click",function(){
				layer.close(index);
			});
		},
		end:function(){
			$(".modal_selectorder").hide();
			$(".modal_selectorderbtn1").unbind("click");
			$(".modal_selectorderbtn2").unbind("click");
			$(".modal_selectorderbtn3").unbind("click");
		}
	});
}
function mda_selectOrder(orderid){
	$(".modal_selectorderlist li[oid='"+orderid+"']").addClass("isselect").siblings().removeClass("isselect");
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getorderdetail'))}",{orderid:orderid},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			var list=result.goods;
			$(".modal_selectorderlist2").empty();
			for(var i in list){
				var temp='<tr><td>'+list[i].goodsn+'</td><td>'+list[i].title+'</td><td>'+list[i].num+'</td><td>'+fee2num(list[i].total_fee)+'</td></tr>';
				$(".modal_selectorderlist2").append(temp);
			}
		}else{
			layer.msg(result.msg,{icon:2,time:1000});
			return false;
		}
	})
}
function fun_selectgoodpcate(pcate){
	$(".right_topmenu .swiper-slide[gcid='"+pcate+"']").addClass("isselect").siblings().removeClass("isselect");
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'getpcategood'))}",{pcate:pcate},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			goodsListSwiper.removeAllSlides();
			var list=result.list;
			if(list.length==0)return;
			var tempAry=[];
			var key=0;
			/*面积计算*/
            var height=$(".right_goodslist .swiper-container").height();
            var width=$(".right_goodslist .swiper-container").width();
            var temp_size=parseInt(height/165)*parseInt(width/170);
            var psize=temp_size;
			for(var i in list){
				if(key==psize){
					goodsListSwiper.appendSlide('<div class="swiper-slide"><ul class="goodlist">'+tempAry.join(" ")+'</ul></div>');
					key=0;
					tempAry=[];
				}
                var temp='<li gid="'+list[i].id+'" title="'+list[i].title+'" goodsn="'+list[i].goodsn+'" store="'+list[i].store+'" price="'+list[i].marketprice+'" mprice="'+list[i].memberprice+'" taste="'+list[i].taste+'"> <A href="javascript:" onclick="fun_selectgood('+list[i].id+')"><div class="img"><img src="'+list[i].thumb+'" onerror="this.src=\'{MODULE_URL}template/resources/img/002.png\';" style="width:100%; height:100px;"></div><div class="info"><h3>';
                var title=list[i].title;
                if(title.indexOf("]")>-1)title=title.replace("[","<b style='color:#F60'>[").replace("]","]</b>");
                temp+=title+'</h3><p><span>￥'+list[i].marketprice+'</span> ';
                if(parseInt(list[i].store)>-1)temp+='<span class="pull-right mstore">剩：'+list[i].store+'</span>';
                temp+='</p></div></A></li>';
                tempAry.push(temp);
                key++;
			}
			if(tempAry.length>0){
				goodsListSwiper.appendSlide('<div class="swiper-slide"><ul class="goodlist">'+tempAry.join(" ")+'</ul></div>');
			}
		}else{
			layer.msg(result.msg,{icon:2,time:1000});
			return;
		}
		
	});
}
function fun_newOrder(orderid){
	if($("#orderid").val()){
		layer.confirm('已有订单在处理，是否挂单？', {}, function(indexd){
			layer.close(indexd);
			fun_munebtn_submitorder(1);
		});
		return;
	}
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'postneworder'))}",{orderid:orderid},function(returnstr){
		layer.close(index2);
		var result=eval("("+returnstr+")");
		if(result.success){
			if(orderid){
				fun_formatMenu(result.trade,result.goods);
				return;
			}
			fun_formatMenu(result.trade);
		}else{
			layer.msg(returnstr,{icon:2,time:1000});
			return;
		}
	});
}

function fun_modal(param){
	layer.open({
		type: 1,
		title:param.title,
		area:'320px',
		skin: 'layui-layer-rim',
		content:$(".modal_counter").show(),
		success: function(layero, index){
            $('#moadConterInput').focus();
            $(document).unbind('keydown').bind('keydown',function(event){
                var keycode=parseInt(event.keyCode);
                if((keycode>=48 && keycode<=57) || (keycode>=96 && keycode<=105)){
                    var temp=keycode<=57 ? 48 : 96;
                    Counter(keycode-temp,'#moadConterInput');
                }else if(keycode==13 || keycode==110){
                    $("#modal_sure").click();
                }else if(keycode==46){
                    Counter(".",'#moadConterInput');
                }else if(keycode==27){
                    if($('#moadConterInput').val()!="0"){
                        $('#moadConterInput').val("0");
                    }else{
                        layer.close(index);
                    }
                    return false;
                }else if(keycode==8 || keycode==116){
                    return false;
                }
            });
			if(!param.type){
				$("#modal_doc").hide();
			}else{
				$("#modal_doc").show();
			}
			if(param.val){
				$('#moadConterInput').val(param.val);
				$('#moadConterInput').select();
			}else{
				$('#moadConterInput').val('');
			}
			if(param.tips){
				$('#moadConterInput').attr("placeholder",param.tips);
			}else{
				$('#moadConterInput').attr('placeholder','');
			}
			$("#modal_cantrl").on("click",function(){
				layer.close(index);
			});
			$("#modal_sure").on("click",function(){
				if(typeof(param.success)=='function'){param.success($('#moadConterInput').val(),index);}
			});

		},
		end:function(){
			$(".modal_counter").hide();
			param=null;
			$("#modal_cantrl").unbind("click");
			$("#modal_sure").unbind("click");
            $(document).unbind("keydown");
		}
	});
}
function Counter(num,obj){
	var vTecla=num;
	var salida=$(obj);
	if(vTecla=='C'){
		salida.val('0');
		if(obj=="#ppl_input_paidfee")fun_paycount();
		return false;
	}
	
	if(vTecla=='B'){
		var temp1=salida.val();
		salida.val(temp1.substr(0,temp1.length-1));
		if(obj=="#ppl_input_paidfee")fun_paycount();
		return false;
	}
	if(vTecla=='.'){
		if(salida.val().indexOf('.')>-1){
			salida.val(salida.val());
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else if(vTecla=='0'){
		if(salida.val()==0 && salida.val().length==1){
			salida.val(0);
		}else{
			salida.val(salida.val()+vTecla);
		}
	}else{
		if((salida.val()==0 && salida.val().length==1)){
			salida.val(vTecla);
		}else{
			salida.val(salida.val()+vTecla);
		} 
	}
	var temp=salida.val();
	if(temp.indexOf('.')>-1){
		var float=temp.split('.');
		if(float[1].length>2){
			salida.val(float[0]+'.'+float[1].substr(0,2));
		}
	}
	if(obj=="#ppl_input_paidfee")fun_paycount();
}
function fun_munebtn_clear(){
	layer.confirm('清空当前订单？<br>清空并不会删除该订单', {}, function(){
		layer.closeAll();
		resetFormInput();
	});
}
function fun_munebtn_submitorder(ishold){
	if(!$("#orderid").val()){
		layer.msg("请先开单",{icon:2,time:1000});
		return;
	}
	var orderid=$("#orderid").val();
	var memberid=parseInt($("#menu_memberid").val());
	var param=[];
	$(".listmenu li").each(function(index, element) {
        var id=$(this).attr("mid")!="undefined" ? $(this).attr("mid") : "";
		var goodid=$(this).attr("gid");
		var price=$(this).attr("price");
		var mprice=$(this).attr("mprice");
		var oprice=$(this).attr("oprice");
		var title=$(this).attr("title");
		var goodsn=$(this).attr("goodsn");
		var num=$(this).find(".txt_num").text();
		var fee=$(this).find(".priceinput").find("span").text().replace("￥","");
		var taste=$(this).find(".taste").text();
		var ispack=$(this).find(".ispack").size();
		var temp=id+"|"+goodid+"|"+goodsn+"|"+title+"|"+price+"|"+mprice+"|"+oprice+"|"+num+"|"+fee+"|"+ispack+"|"+taste;
		param.push(temp);
    });
	var index2=layer.load(1, {shade: [0.1,'#fff']});
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'submitorder'))}",{param:param,orderid:orderid,memberid:memberid},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		if(result.success){
			if(ishold){
				resetFormInput();
			}else{
				fun_startPay(orderid);
			}
		}else{
			layer.msg(result.msg,{icon:2,time:1000});
			return;
		}
	});
}
function resetFormInput(){
	$("#Txt_search").val('');
	$("#txt_tablename").text('');
	$("#orderid").val('');
	$("#menu_membercash").text('0.00');
	$("#menu_membercardno").text('');
	$("#menu_memberid").val('');
	$("#menu_discount").val('100');
	$("#menu_order").text("0.00");
	$("#menu_couponfee").text("0.00");
	$("#menu_total").text("0.00");
	$("#form_menu")[0].reset();
	$("#btn_getback").show();
	$("#btn_submitorder").hide();
	$(".temp_1 .til span").text('');
	$(".temp_1 .num span").text('');
	menuListSwiper.removeAllSlides();
}
function fun_formatMenu(trade){
	resetFormInput();
	$("#txt_tablename").text(trade.serialnum);
	$("#orderid").val(trade.id);
	$("#menu_memberid").val(trade.memberno);
	if(trade.ispay==0){
		$("#btn_getback").hide();
		$("#btn_submitorder").show();
	}else if(trade.ispay==1){
		$("#btn_getback").hide();
		$("#btn_submitorder").hide();
	}
	if(trade.memberno){
		var index2=layer.load(1, {shade: [0.1,'#fff']});
		$.post("{php echo $this->createMobileUrl('index',array('op'=>'getmember'))}",{memberid:trade.memberno},function(returnstr){
			layer.close(index2);
			console.log(returnstr);
			var result=eval("("+returnstr+")");
			if(result.success){
				var member=result.member;
				var cardname=member.realname;
				if(!cardname)cardname=member.cardno;
				$("#menu_membercardno").text(cardname);
				$("#menu_membercash").text(member.cash2);
			}
		});
	}
	if(arguments.length<2)return;
	var goods=arguments[1];
	for(var i in goods){
		var temp='<li class="swiper-slide" isnew="false" mid="'+goods[i].id+'" title="'+goods[i].title+'" goodsn="'+goods[i].goodsn+'" gid="'+goods[i].goodid+'" price="'+goods[i].price+'" mprice="'+goods[i].memberprice+'" oprice="'+goods[i].oldprice+'" onclick="fun_selectmenu(this)"><div class="til">'+goods[i].title+'<div class="taste">'+goods[i].taste+'</div>';
		temp+='<div class="extension">';
		if(parseInt(goods[i].ispack))temp+='<span class="red">打包</span>';
		if(parseInt(goods[i].ispay))temp+='<span class="green">已付</span>';
		temp+='</div></div><div class="numinput"> <span class="txt_num">'+goods[i].num+'</span> </div><div class="priceinput"> ';
		var total=parseInt(str2num(goods[i].price))*parseInt(goods[i].num);
		if(total==parseInt(goods[i].total_fee)){
			temp+='<span>￥'+fee2num(total)+'</span> <s></s></div>';
		}else{
			temp+='<span>￥'+fee2num(goods[i].total_fee)+'</span> <s>￥'+fee2num(total)+'</s></div>';
		}
		temp+='</li>';
		menuListSwiper.prependSlide(temp);
	}
	$(".listmenu").css("overflow","visible");
	menuListSwiper.updateSlidesSize();
	menuListSwiper.slideTo(0);
	fun_sumTotal();
}

function funExtend_btn(obj){
	var url=$(obj).attr("url");
	var title=$(obj).text();
	var _height=$(window).height();
	var _width=$(window).width();
	layer.open({
	  type: 2,
	  title:title,
	  shadeClose: true,
	  shade: 0.8,
	  area: [_width+'px', _height+'px'],
	  content: url
	}); 
}

function fee2num(num){
    if(num=="")return 0;
    if(isNaN(parseFloat(num)))return 0;
    if(num.toString().indexOf(".")>-1){
        return (parseFloat(num)).toFixed(2);
    }
    var fee=(parseInt(num)*0.01).toFixed(2);
    return fee;
}
function fromatTime(time){
	var datetime = new Date();
	datetime.setTime(time*1000);
	var year = datetime.getFullYear();
	var month = datetime.getMonth() + 1;
	var date = datetime.getDate();
	var hour = datetime.getHours();
	var minute = datetime.getMinutes();
	var second = datetime.getSeconds();
	var mseconds = datetime.getMilliseconds();
	if(hour<10)hour="0"+hour;
	if(month<10)month="0"+month;
	if(minute<10)minute="0"+minute;
	
	var timetype="m/d h:i";
	if(arguments[1])timetype=arguments[1];
	timetype=timetype.replace("y",year);
	timetype=timetype.replace("m",month);
	timetype=timetype.replace("d",date);
	timetype=timetype.replace("h",hour);
	timetype=timetype.replace("i",minute);
	timetype=timetype.replace("s",second);
	return timetype;
}
function fun_print(ptype,orderid){
	var iskey=arguments.length>2 ? arguments[2] : '';
	layer.load(1,{shade: [0.1,'#fff'],time:2000},function(){
        if(typeof(iskey)=="function")iskey();
    });
    if(typeof(iskey)=="function")iskey="";
	$("#print_iframe").removeAttr("src").attr("src","{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&ptype="+ptype+"&m=j_hmoney&do=print&orderid="+orderid+"&iskey="+iskey+"&userid={php echo $userid}");
}


function initKeypree(type){
    if(type==0){
        $(document).unbind("keydown");
    }else{

    }
}
/*window.onbeforeunload = function(e){
	return e.returnValue='';
};*/
</script>